package prototipo.server.logic.transaction;

import prototipo.server.logic.exception.ExceptionLogic;
import prototipo.server.logic.item.Item;
import prototipo.server.logic.util.Money;

public class ItemPay implements ItemPayIF {
	private Item item;
	private int amount;
	private Money value;
	private boolean nf;

	/**
	 * @param item
	 * @param amount1
	 * @param value
	 * @throws ExceptionLogic
	 */
	public ItemPay(Item item, int amount, Money value, boolean nf)
			throws ExceptionLogic {
		super();
		this.setItem(item);
		this.setAmount(amount);
		this.setValue(value);
	}

	/**
	 * @return the item
	 */
	public Item getItem() {
		return item;
	}

	/**
	 * @param item
	 *            the item to set
	 * @throws ExceptionLogic
	 */
	public void setItem(Item item) throws ExceptionLogic {
		if (item == null)
			throw new ExceptionLogic("Item vazio.", new Throwable(
					"Item is null."));
		this.item = item;
	}

	/**
	 * @return the amount
	 */
	public int getAmount() {
		return amount;
	}

	/**
	 * @param amount
	 *            the amount to set
	 * @throws ExceptionLogic
	 */
	public void setAmount(int amount) throws ExceptionLogic {
		if (amount < 0)
			throw new ExceptionLogic("Montante negativo.", new Throwable(
					"Amount is negative."));
		this.amount = amount;
	}

	/**
	 * @return the value
	 */
	public Money getValue() {
		return value;
	}

	/**
	 * @param value
	 *            the value to set
	 * @throws ExceptionLogic
	 */
	public void setValue(Money value) throws ExceptionLogic {
		if (value == null)
			throw new ExceptionLogic("Valor vazio.", new Throwable(
					"Money is null."));
		this.value = value;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof ItemPay))
			return false;
		ItemPay other = (ItemPay) obj;
		if (item == null) {
			if (other.item != null)
				return false;
		} else if (!item.equals(other.item))
			return false;
		return true;
	}

	/**
	 * @return the nf
	 */
	public boolean isNf() {
		return nf;
	}

	/**
	 * @param nf
	 *            the nf to set
	 */
	public void setNf(boolean nf) {
		this.nf = nf;
	}

}
